﻿<!--
MainWindow.xaml
Author: Daniel Sklenitzka

Copyright 2013 The CWC Team

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<Window x:Class="CkMp.Generator.UI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:g="clr-namespace:Genesis.UI"
        Title="CWC Map Generator" SizeToContent="WidthAndHeight" ResizeMode="CanMinimize" Icon="CWCMapGenerator.ico">
    
    <DockPanel LastChildFill="True" Width="920" Background="{StaticResource GradientBrush}">

        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File" >
                <MenuItem Header="_Save" Command="{Binding SaveCommand}"/>
                <MenuItem Header="E_xit"  Click="Close"/>
            </MenuItem>
            <MenuItem Header="_Generator" >
                <MenuItem Header="_New Map" ToolTip="Generate a new map using a random map #." Command="{Binding NewMapCommand}"/>
                <MenuItem Header="_Generate" ToolTip="Generate a map based on the current map # and settings." Command="{Binding GenerateCommand}"/>
                <MenuItem Header="_Cancel" ToolTip="Cancel the current generation." Command="{Binding CancelCommand}"/>
            </MenuItem>
            <MenuItem Header="_Options">
                <MenuItem Header="_Options" Click="EditOptions"/>
                <MenuItem Header="_About" Click="ShowAboutBox"/>
            </MenuItem>
        </Menu>
        
        <Grid Margin="10" Name="content">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            
            <Grid Grid.Column="0" Grid.Row="0" Name="grid">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>                    
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="22"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="22"/>
                </Grid.RowDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Text="Map #:" Style="{StaticResource DefaultStyle}"/>
                <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Settings.MapId, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DefaultStyle}"/>

                <Button Grid.Row="1" Grid.Column="1" Content="New Map" ToolTip="Generate a new map using a random map #." Command="{Binding NewMapCommand}" Style="{StaticResource DefaultStyle}"/>

                <Border Grid.Row="2" Grid.ColumnSpan="2" BorderThickness="0,0,0,0" BorderBrush="LightGray" Margin="0,11" HorizontalAlignment="Stretch">
                    <TextBlock TextWrapping="Wrap" Text="You can modify the settings of the map below. Press 'Generate' afterwards to apply your changes." Foreground="gray"/>
                </Border>

                <TextBlock Grid.Row="3" Grid.Column="0" Text="Number of Players:" Style="{StaticResource DefaultStyle}"/>
                <ComboBox Grid.Row="3" Grid.Column="1" ItemsSource="{Binding Settings.Players}" SelectedItem="{Binding Settings.NumberOfPlayers}" Style="{StaticResource DefaultStyle}"/>

                <TextBlock Grid.Row="4" Grid.Column="0" Text="Size:" Style="{StaticResource DefaultStyle}"/>
                
                <Grid Grid.Row="4" Grid.Column="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <TextBox Grid.Column="0" Text="{Binding Settings.Width, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True, ValidatesOnDataErrors=True}" Style="{StaticResource DefaultStyle}" TextAlignment="Right" />
                    <TextBlock Grid.Column="1" Text="x" Margin="5,0" />
                    <TextBox Grid.Column="2" Text="{Binding Settings.Height, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=True, ValidatesOnDataErrors=True}" Style="{StaticResource DefaultStyle}" TextAlignment="Right"/>
                </Grid>
                
                <TextBlock Grid.Row="6" Grid.Column="0" Text="Scenery:" Style="{StaticResource DefaultStyle}"/>
                <ComboBox Grid.Row="6" Grid.Column="1" ItemsSource="{Binding Settings.Sceneries}" SelectedItem="{Binding Settings.Scenery}" DisplayMemberPath="Name" Style="{StaticResource DefaultStyle}"/>

                <TextBlock Grid.Row="7" Grid.Column="0" Text="Number of Mountains:" Style="{StaticResource DefaultStyle}"/>
                <ComboBox Grid.Row="7" Grid.Column="1" ItemsSource="{Binding Settings.Frequencies}" SelectedItem="{Binding Settings.CliffFrequency}" Style="{StaticResource DefaultStyle}"/>

                <TextBlock Grid.Row="8" Grid.Column="0" Text="Number of Trees:" Style="{StaticResource DefaultStyle}"/>
                <ComboBox Grid.Row="8" Grid.Column="1" ItemsSource="{Binding Settings.Frequencies}" SelectedItem="{Binding Settings.TreeFrequency}" Style="{StaticResource DefaultStyle}"/>

                <TextBlock Grid.Row="9" Grid.Column="0" Text="Time of Day:" Style="{StaticResource DefaultStyle}"/>
                <ComboBox Grid.Row="9" Grid.Column="1" ItemsSource="{Binding Settings.TimesOfDay}" SelectedItem="{Binding Settings.TimeOfDay}" Style="{StaticResource DefaultStyle}"/>
            </Grid>

            <Grid Grid.Column="0" Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Button Grid.Column="0" Content="Save Map" ToolTip="Save the last map you generated." Command="{Binding SaveCommand}" Style="{StaticResource DefaultStyle}"/>
                <Button Grid.Column="1" Content="Generate" ToolTip="Generate a map based on the current map # and settings." Command="{Binding GenerateCommand}" Style="{StaticResource DefaultStyle}"/>
            </Grid>

            <DockPanel Grid.Column="2" MaxHeight="{Binding ActualHeight, ElementName=grid}" LastChildFill="True">
                <g:Preview DataContext="{Binding Preview}"/>
            </DockPanel>

            <TextBox Name="log" Grid.Column="4" IsReadOnly="True" Text="{Binding Messages, Mode=OneWay}" ScrollViewer.VerticalScrollBarVisibility="Auto" TextChanged="ScrollToEnd" MaxHeight="{Binding ActualHeight, ElementName=grid}"/>

            <DockPanel Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="3" LastChildFill="True" Visibility="{Binding ShowSaveInfo, Converter={StaticResource BooleanToVisibilityConverter}}" VerticalAlignment="Center">
                <TextBlock DockPanel.Dock="Left"  Text="The map was saved in "/>
                <TextBlock>
                    <Hyperlink Click="OpenPath">
                        <TextBlock Name="path" Text="{Binding SaveInfo}" TextTrimming="CharacterEllipsis"/>
                    </Hyperlink>.
                </TextBlock>
            </DockPanel>
        </Grid>
    </DockPanel>
</Window>
